I've learned some shells before, but not very deep, and the time to write code is not much. Shortly before the shell was more thin, leader assigned a task to write a script with the shell to upload the Redis source tarball from one server to another
[Turn]http://www.knktc.com/2011/08/20/linux-shell-expect%e6%89%b9%e9%87%8fscp%e8%84%9a%e6%9c%ac%e5%b7%a5%e5%85%b7/
One of the most recent tasks in preparing a deployment is to send some files, such as installation packages, to a large number of
When deploying a task, one of the necessary procedures is to send some files, such as installation packages, to a large number of servers. Although there is already a Brother Woo script available: A Python script written by the SSH and SCP features
SCP is very powerful, but requires manual input of password, of course, you can save the public key in the remote host's ~/.ssh directory, and then do not enter password, but this needs to be configured.Use Sshpass may enter password in command, but
Wrote a script to transfer the file, similar to this:Sendsystem (){Expect-c "Spawn SCP$ORACLE _base/oradata/$oracle_sid/system01.dbf [email protected]$S _ip:$Oracle_base/oradata/standby/expect{Yes/no{Send\"Yes\ r\";
Experimental environment1. Local Host192.168.1.172. Remote Host192.168.1.18192.168.1.19Experimental objectivesUse expect non-interactive scripting with SCP commands to implement SCP bulk transfer of local files to a remote host.Scripting
The script is as follows:
#!/usr/bin/expect-f
Set Password Password
Spawn SCP username @ Target Machine IP: Path of the copy file location of local files
Set Timeout 300
Expect "user name @ Target machine IP ' password:" #注意: "User name @
Recent project requirements, need to write some shell script interaction, the pipeline is not enough time, expect can be very good to implement the interaction between the script, search for information, found that many articles on the Web are
Upload the backup SQL files from one server to the corporate local server but the company's local server did key verification, that is, to use key to log on to the local server, as well as the external network of the server did not do key
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.